$(function(){

    $("#submit").tap(function(){
        var data = $('#login').serializeArray();
        data = unSerializeArray(data)
        if (!data.username) {
            alert('用户名不能为空！');
            return false;
        }
        if (!data.password) {
            alert('密码不能为空！');
            return false;
        }
        data.postType = 'login'; //用来区分该数据来源于哪个请求

        var option = {
            type: 'post',
            data: data,
            url: Api.loginUrl
        };
        requestEvent(option).then(function (res) {
            var status = res.status;
            if(status == 1){
                alert("登录成功！");
                window.open("home.html","_self");
            }else if(status == 2){
                alert("你还未注册");
            }else{
                alert("密码错误");
            }
        }, function (error) {
            console.log(error);
        })


    });



});
